<template>
	<view>
		<header-common title="活动" :iconShow="false"></header-common>
		<!-- 插入一个日历 -->
		<uv-calendars insert :selected="selected" @change="change" />


		<uv-popup ref="popup" round="12" @change="popupChange">
			<view class="popup-box">
				<view class="title">
					<text>
						活动标题
						<!-- {{popupVlaue.title}} -->
					</text>
					<view class="icon-close" @click="close">
					<uv-icon  name="close-circle" size="22"></uv-icon>
					</view>
				</view>
				<!-- 具体内容 -->
				<view class="popup-text">
					丙辰中秋，欢饮达旦，大醉，作此篇，兼怀子由。 明月几时有？把酒问青天。
					不知天上宫阙，今夕是何年。我欲乘风归去，又恐琼楼玉宇，高处不胜寒。起舞弄清影，何似在人间。
					转朱阁，低绮户，照无眠。不应有恨，何事长向别时圆？人有悲欢离合，月有阴晴圆缺，此事古难全。
					但愿人长久，千里共婵娟。
					</view>
			</view>
		</uv-popup>

		<tabbar :index="2"></tabbar>
	</view>
</template>

<script>
	import {request_calendar} from '@/api/axios.js'
	export default {
		data() {
			return {
				selected: [],
				popupVlaue: {},
				popShow: false,
			}
		},
		onLoad() {
			this.getCalendar();
			// console.log(this.selected);
		},
		onShow(){
			this.getCalendar();
			console.log("show");
		},
		methods: {
			// 初始化, 获取行程表
			async getCalendar() {
				/* const token = uni.getStorageSync('token')
				this.selected = (await request_calendar({id:token})).data */

				this.selected = [{
						date: "2025-01-02",
						info: "签到",
						badge: true,
						infoColor: "#ff0000"
					},
					{
						date: "2025-01-06",
						info: "余10",
						infoColor: "#19be6b",
						topinfo: "￥100",
						topinfoColor: "#19be6b"
					},
					{
						date: "2025-01-19",
						info: "秋游",
						infoColor: "pink",
						topinfo: "顶部文字",
						topinfoColor: "#19be6b"
					},
					{
						date: "2025-02-08",
						info: "开会",
						badge: true,
						infoColor: "red"
					},
					{
						date: "2025-01-08",
						info: "开会",
						badge: true,
						infoColor: "red",
						data: {
							id: 123,
							content: '内容'
						}
					},
				]
			},
			change(e) {
				// console.log(e)
				// 判断当前日期是否有行程安排
				if (e.extraInfo.date) {
					this.popupVlaue = e.extraInfo.data;
					// 打开弹窗
					this.$refs.popup.open('bottom');
				}
				// 打开下拉框, 展示当天具体活动安排
			},
			close() {
				this.popupVlaue = {};
				this.$refs.popup.close();
			},
			popupChange(e) {
				console.log('弹窗状态改变：', e);
			}

		}
	}
</script>

<style lang="scss" scoped>
	
	.popup-box{
		position: relative;
		// padding: 24rpx;
		padding: 24px 24rpx 120px;
		box-sizing: border-box;
	}
	.popup-box .title{
		width: 100%;
		position: relative;
		text-align: center;
		height: 60rpx;
		line-height: 60rpx;
		font-size: 32rpx;
		font-weight: bold;
		margin-bottom: 12px;
	}
	.icon-close{
		width: 60rpx;
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 0rpx;
		right: 8rpx;
		// padding: 24rpx;
		// background-color: red;
	}
	
	.popup-text{
		text-indent: 2em;
	}

</style>